#!/usr/bin/env python
# -*- coding: utf-8 -*-

# pywordlist.It's a WordList Maker
# Copyright (C) 2009,res0w
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

'''
Created on 2009-11-24

@author: res0w
'''
import sys,cmd
from datetime import date
from core import *


class Cli(cmd.Cmd):
    '''解析命令行'''
    def __init__(self):
        cmd.Cmd.__init__(self)
        self.prompt="wordlist> "
        
    def default(self,line):
        print line,u"unSupport Command"
        
    def help_ranlist(self):
        print u'''生成随机单词列表\n
可以添加参数，如果无参数默认生成10个words'''
    def do_ranlist(self,args):
        print '==========='
        if args!='':
            core.showRanList(args)
        else:
            core.showRanList()
       input=raw_input('===========\n是否保存？') 
        if input in ['y','yes']: 
            print 'saving...please wait'
            core.writeRanList()
            print 'done!'
	else if input in ['n','no']: 
            print 'done without save'		
        
    def help_exit(self):
        print u'退出程序'
    def do_exit(self,arg):
        print 'exit'
        sys.exit(0)

if __name__ == '__main__':
    '''CLI Mode'''
    cli=Cli()
    welcomeinfo='''===========================================\n
    Welcome to use WordsList AutoMaker...\n
    It's a demo written by python\n
    输入help可以查看帮助\n
===========================================\n'''
    print welcomeinfo
    cli.cmdloop()
